package com.usian.search.controller;

import com.usian.apis.search.ArticleSearchControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.search.dtos.UserSearchDto;
import com.usian.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/search")
public class ArticleSearchController implements ArticleSearchControllerApi {

    @Autowired
    private SearchService searchService;

    @Override
    @PostMapping("/search")
    public ResponseResult search(@RequestBody UserSearchDto dto) {
        return searchService.search(dto);
    }

    /***
     * 文章历史记录查询
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load")
    public ResponseResult findUserSearch(@RequestBody UserSearchDto dto) {
        return searchService.findUserSearch(dto);
    }

    /***
     * 删除
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/del")
    public ResponseResult delUserSearch(@RequestBody UserSearchDto dto) {
        return searchService.delUserSearch(dto);
    }
}
